/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div>
      <div class="fixed-bar">
        <div class="item-title">
          <router-link
            class="back"
            :to="{name:'returned',params:{currentPage:$route.params.currentPage,status:$route.params.status}}"
            title="返回列表"
          >
            <i class="fa fa-arrow-circle-o-left"></i>
          </router-link>
          <div class="subject">
            <h3>退货管理 - 查看退单“退单编号：{{order.order_sn}}”</h3>
            <h5>商品订单退货申请及审核处理</h5>
          </div>
        </div>
      </div>
      <form class="form-horizontal" id="handleposition" method="post">
        <div class="ncap-form-default">
          <div class="title">
            <h3>买家退货退款申请</h3>
          </div>
          <dl class="row">
            <dt class="tit">申请时间</dt>
            <dd class="opt">{{return_goods.add_time_format}}</dd>
          </dl>
          <dl class="row">
            <dt class="tit">商品名称</dt>
            <dd class="opt">{{order_goods.goods_name}}</dd>
          </dl>
          <dl class="row">
            <dt class="tit">退款金额</dt>
            <dd class="opt">
              {{return_goods.refund_money}}
              <label
                v-if="return_goods.refund_deposit > 0"
              >退还余额：{{return_goods.refund_deposit}}</label>
              <label v-if="return_goods.refund_integral > 0">退还积分：{{return_goods.refund_integral}}</label>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">退货原因</dt>
            <dd class="opt">{{return_goods.reason}}</dd>
          </dl>
          <dl class="row">
            <dt class="tit">退货数量</dt>
            <dd class="opt">{{return_goods.goods_num}}</dd>
          </dl>
          <dl class="row">
            <dt class="tit">退货说明</dt>
            <dd class="opt">{{return_goods.describe}}</dd>
          </dl>
          <dl class="row">
            <dt class="tit">凭证上传</dt>
            <dd class="opt" v-if="return_goods.imgs != ''">
              <el-image
                style="width: 100px; height: 100px"
                :src="return_goods.imgs_url[0]"
                :preview-src-list="return_goods.imgs_url"
              ></el-image>
            </dd>
          </dl>
          <div class="title">
            <h3>商家退款退货处理</h3>
          </div>
          <dl class="row">
            <dt class="tit">审核结果</dt>
            <dd class="opt">{{return_goods.status_desc}}</dd>
          </dl>
          <dl class="row">
            <dt class="tit">处理备注</dt>
            <dd class="opt">{{return_goods.remark}}</dd>
          </dl>
          <dl class="row">
            <dt class="tit">处理时间</dt>
            <dd class="opt" v-if="return_goods.checktime > 0">{{return_goods.check_time_format}}</dd>
          </dl>
          <div class="title">
            <h3>订单支付信息</h3>
          </div>
          <dl class="row">
            <dt class="tit">支付方式</dt>
            <dd class="opt" v-if="order.pay_name == '' && order.pay_status == 1">{{order.pay_name}}</dd>
            <dd class="opt" v-else>{{order.pay_name}}</dd>
          </dl>
          <dl class="row">
            <dt class="tit">订单总额</dt>
            <dd class="opt">{{order.total_amount}}</dd>
          </dl>
          <div class="title" v-if="return_goods.status == 3 || return_goods.status == 5">
            <h3>平台退款审核</h3>
          </div>
          <dl class="row" v-if="return_goods.status == 3">
            <dt class="tit">退款方式</dt>
            <dd class="opt">
              <el-radio v-model="return_goods.refund_type" label="1" border size="medium">退到预存款</el-radio>
              <el-radio v-model="return_goods.refund_type" label="0" border size="medium">支付原路退还</el-radio>
            </dd>
          </dl>
          <dl class="row" v-if="return_goods.status == 3">
            <dt class="tit">备注信息</dt>
            <dd class="opt">
              <el-input
                type="textarea"
                :rows="2"
                placeholder="请输入内容"
                v-model="return_goods.refund_mark"
              ></el-input>
            </dd>
            <p class="notic">系统默认退款到“站内余额”，如果“在线退款”到原支付账号，建议在备注里说明，方便核对。</p>
          </dl>
          <dl class="row" v-if="return_goods.status == 5">
            <dt class="tit">平台确认</dt>
            <dd class="opt">已完成</dd>
          </dl>
          <dl class="row" v-if="return_goods.status == 5">
            <dt class="tit">处理备注</dt>
            <dd class="opt">{{return_goods.refund_mark}}</dd>
          </dl>
          <dl class="row" v-if="return_goods.status == 5">
            <dt class="tit">处理时间</dt>
            <dd class="opt">{{return_goods.refund_time | datefmtAll}}</dd>
          </dl>
          <div class="title" v-if="return_goods.status == 5">
            <h3>退款详细</h3>
          </div>
          <dl class="row" v-if="return_goods.status == 5">
            <dt class="tit">支付方式</dt>
            <dd class="opt">{{return_goods.refund_type == 0 ? "在线原路退回" : "站内余额支付"}}</dd>
          </dl>
          <dl class="row" v-if="return_goods.status == 5">
            <dt class="tit">退还预存款</dt>
            <dd class="opt">{{return_goods.refund_deposit}}</dd>
          </dl>
          <dl class="row" v-if="return_goods.status == 5">
            <dt class="tit">退款金额</dt>
            <dd class="opt">{{return_goods.refund_money}}</dd>
          </dl>
          <div class="bot" v-if="return_goods.status == 3">
            <a @click="onSubmit()" class="ncap-btn-big ncap-btn-green">确认提交</a>
          </div>
        </div>
      </form>
    </div>
  </div>
</template>

<script>
	import {
		getReturnGoods,
		getOrder,
		getOrderGoods,
		refundReturnGoods
	} from "@/utils/api.js";
export default {
  data() {
    return {
      return_goods: {},
      order_goods: {},
      order: {}
    };
  },
  created() {
    this.getReturnGoods();
  },
  methods: {
    onSubmit() {
      var that = this;
        refundReturnGoods(this.return_goods).then(function(res) {
          if (res.status == 1) {
            that.$message({
              type: "success",
              message: "操作成功!",
              onClose: function() {
                that.getReturnGoods();
              }
            });
          } else {
            that.$message.error({
              message: res.msg
            });
          }
        });
    },
    getReturnGoods() {
      var that = this;
        getReturnGoods({id: this.$route.params.id}).then(function(res) {
          that.return_goods = res;
		  that.getOrderGoods();
        });
    },
    getOrderGoods() {
      var that = this;
        getOrderGoods({rec_id: that.return_goods.rec_id}).then(function(res) {
          that.order_goods = res;
          that.getOrder();
        });
    },
    getOrder() {
      var that = this;
        getOrder({ order_id: that.order_goods.order_id}).then(function(res) {
          that.order = res;
        });
    }
  }
};
</script>

<style scoped>
</style>
